#include "StdAfx.h"
#include "LogoutCommander.h"

LogoutCommander::LogoutCommander(void):LoginCommander()
{
}

LogoutCommander::~LogoutCommander(void)
{
}

int LogoutCommander::ProcessCommand( void )
{
	if (m_UserName.empty() || m_Password.empty())
	{
		return COMMAND_INVALID_INPUT;
	}
	if (!m_OnlineStatus.isOnline())
	{
		return COMMAND_INVALID_CONN;
	}

	// build up logout message
	CMarkup xmlLogout;
	xmlLogout.AddElem(_T("IPIN")); 
	xmlLogout.AddChildElem(_T("Type"), CLIENT_EXIT);
	xmlLogout.AddChildElem(_T("Info"));
	xmlLogout.IntoElem();
	if (m_UserName.find(_T("@")) > 0)
		xmlLogout.AddChildElem(_T("Email"), m_UserName.c_str());
	else
		xmlLogout.AddChildElem(_T("UID"), m_UserName.c_str());

	m_Command = xmlLogout.GetDoc();
	int ConnRsp = SendCommand();

	return COMMAND_OK;
}